package com.xcity.game.activity.newplayer;

import java.util.Set;

import gnu.trove.map.TByteObjectMap;
import gnu.trove.map.hash.TByteObjectHashMap;
import naga.x.util.ClassUtil;

public class NewPlayerTracerFactory {
	protected static TByteObjectMap<NewPlayerTracer> tid2tracer = new TByteObjectHashMap<NewPlayerTracer>();
	
	static{
		String pkg = NewPlayerTracerFactory.class.getPackage().getName() + ".tracer";
		Set<Class<?>> classes = ClassUtil.scanPackage(pkg);
		for(Class<?> cls : classes){
			if(NewPlayerTracer.class.isAssignableFrom(cls)){
				try {
					NewPlayerTracerLabel label = cls.getDeclaredAnnotation(NewPlayerTracerLabel.class);
					NewPlayerTracer tracer = (NewPlayerTracer) cls.newInstance();
					tid2tracer.put(label.value(), tracer);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
	}
	
	public static NewPlayerTracer creat(byte type){
		return tid2tracer.get(type);
	}
}
